CREATE TABLE  "CADENAHOTEL" 
   (	"IDCADENAHOTEL" NUMBER(9,0), 
	"NOMBRECADENA" VARCHAR2(90), 
	 CONSTRAINT "IDCADENAHOTEL_PK" PRIMARY KEY ("IDCADENAHOTEL") ENABLE
   )
/
CREATE TABLE  "CLIENTE" 
   (	"IDCLIENTE" NUMBER(9,0), 
	"NOMBRECLIENTE" VARCHAR2(90), 
	"DIRECCIONCLIENTE" VARCHAR2(90), 
	"TELEFONO" NUMBER NOT NULL ENABLE, 
	"CORREOELEC" VARCHAR2(4000) NOT NULL ENABLE, 
	 CONSTRAINT "IDCLIENTE_PK" PRIMARY KEY ("IDCLIENTE") ENABLE
   )
/
CREATE TABLE  "CHECKIN" 
   (	"IDCHECKIN" NUMBER(9,0), 
	"HORA" VARCHAR2(60), 
	"FECHA" DATE, 
	"CODCLIENTE" NUMBER(9,0), 
	 CONSTRAINT "IDCHECKIN_PK" PRIMARY KEY ("IDCHECKIN") ENABLE, 
	 CONSTRAINT "CODCLIENTE_FK" FOREIGN KEY ("CODCLIENTE")
	  REFERENCES  "CLIENTE" ("IDCLIENTE") ON DELETE SET NULL ENABLE
   )
/
CREATE TABLE  "CHECKOUT" 
   (	"IDCHECKOUT" NUMBER(9,0), 
	"HORA" NUMBER(9,0), 
	"FECHA" DATE, 
	"CLIENTE_CHECKOUT" NUMBER(9,0), 
	 CONSTRAINT "IDCHECKOUT_PK" PRIMARY KEY ("IDCHECKOUT") ENABLE, 
	 CONSTRAINT "CLIENTE_FK" FOREIGN KEY ("CLIENTE_CHECKOUT")
	  REFERENCES  "CLIENTE" ("IDCLIENTE") ENABLE
   )
/
CREATE TABLE  "CONVENIO" 
   (	"IDCONVENIO" NUMBER(9,0), 
	"NOMBREAGENCIA" VARCHAR2(90), 
	"NIT" NUMBER(9,0), 
	"DESCRIPCIONCONVENIO" VARCHAR2(90), 
	"REPRESENTANTECONVENIO" VARCHAR2(60), 
	"CADENA" NUMBER(9,0), 
	"FECHAINGRESO" DATE, 
	"PERIODODURACION" DATE NOT NULL ENABLE, 
	 CONSTRAINT "IDCONVENIO_PK" PRIMARY KEY ("IDCONVENIO") ENABLE, 
	 CONSTRAINT "CADENACONVENIO_FK" FOREIGN KEY ("CADENA")
	  REFERENCES  "CADENAHOTEL" ("IDCADENAHOTEL") ON DELETE SET NULL ENABLE
   )
/
CREATE TABLE  "DEPARTAMENTO" 
   (	"IDDEPARTAMENTO" NUMBER(9,0), 
	"NOMBREDEPARTAMENTO" VARCHAR2(40), 
	 CONSTRAINT "IDDEPARTAMENTO_PK" PRIMARY KEY ("IDDEPARTAMENTO") ENABLE
   )
/
CREATE TABLE  "FACTURA" 
   (	"IDFACTURA" NUMBER(9,0), 
	"IMPUESTO" NUMBER(9,0), 
	"CLIENTE_FACTURA" NUMBER(9,0), 
	"DESCUENTO" NUMBER(9,0), 
	 CONSTRAINT "FACTURA_PK" PRIMARY KEY ("IDFACTURA") ENABLE, 
	 CONSTRAINT "CLIENTE_FACTURAFK" FOREIGN KEY ("CLIENTE_FACTURA")
	  REFERENCES  "CLIENTE" ("IDCLIENTE") ENABLE
   )
/
CREATE TABLE  "REGISTROCONSUMIBLE" 
   (	"IDREGISTRO" NUMBER(9,0), 
	"PRODUCTOCONSUMIBLE" NUMBER(9,0), 
	"FECHA" DATE, 
	"HOTEL" VARCHAR2(90), 
	"HABITACION" NUMBER(9,0), 
	"CLIENTEREGISTRO" NUMBER(9,0), 
	 CONSTRAINT "IDREGISTRO_PK" PRIMARY KEY ("IDREGISTRO") ENABLE, 
	 CONSTRAINT "CLIENTEREGISTRO_FK" FOREIGN KEY ("CLIENTEREGISTRO")
	  REFERENCES  "CLIENTE" ("IDCLIENTE") ON DELETE SET NULL ENABLE
   )
/
CREATE TABLE  "PRODUCTOCONSUMIBLE" 
   (	"IDCONSUMIBLE" NUMBER(9,0), 
	"NOMBREPCONSUMIBLE" VARCHAR2(60), 
	"PRECIOPRODUCTO" NUMBER(12,4), 
	"MARCAPCONSUMIDO" VARCHAR2(90), 
	"FECHAVENCIMIENTO" VARCHAR2(90), 
	"REGISTROCONSUMIBLE" NUMBER(9,0), 
	 CHECK (precioProducto>=0) ENABLE, 
	 CONSTRAINT "IDCONSUMIBLE_PK" PRIMARY KEY ("IDCONSUMIBLE") ENABLE, 
	 CONSTRAINT "REGISTROCONSUMIBLE_FK" FOREIGN KEY ("REGISTROCONSUMIBLE")
	  REFERENCES  "REGISTROCONSUMIBLE" ("IDREGISTRO") ON DELETE SET NULL ENABLE
   )
/
CREATE TABLE  "DETALLEFACTURA" 
   (	"IDDETALLEFACTURA" NUMBER(9,0), 
	"NUMEROITEM" NUMBER(9,0), 
	"CANTIDAD" NUMBER(10,6), 
	"DESCUENTO" NUMBER(10,6), 
	"FACTURA" NUMBER(9,0), 
	"PRODUCTOCONSUMIBLE" NUMBER(9,0), 
	 CONSTRAINT "IDDETALLE_PK" PRIMARY KEY ("IDDETALLEFACTURA") ENABLE, 
	 CONSTRAINT "FACTURA_FK" FOREIGN KEY ("FACTURA")
	  REFERENCES  "FACTURA" ("IDFACTURA") ON DELETE SET NULL ENABLE, 
	 CONSTRAINT "PRODUCTO_FK" FOREIGN KEY ("PRODUCTOCONSUMIBLE")
	  REFERENCES  "PRODUCTOCONSUMIBLE" ("IDCONSUMIBLE") ON DELETE SET NULL ENABLE
   )
/
CREATE TABLE  "INVENTARIO" 
   (	"IDINVENTARIO" NUMBER(9,0), 
	"PRODUCTOCONSUMIBLE" NUMBER(9,0), 
	"CADENAHOTEL" NUMBER(9,0), 
	"HOTEL" NUMBER(9,0), 
	 CONSTRAINT "IDINVENTARIO_PK" PRIMARY KEY ("IDINVENTARIO") ENABLE, 
	 CONSTRAINT "PRODUCTOCONSUMIBLEIN_FK" FOREIGN KEY ("PRODUCTOCONSUMIBLE")
	  REFERENCES  "PRODUCTOCONSUMIBLE" ("IDCONSUMIBLE") ON DELETE SET NULL ENABLE, 
	 CONSTRAINT "CADENAHOTELIN_FK" FOREIGN KEY ("CADENAHOTEL")
	  REFERENCES  "CADENAHOTEL" ("IDCADENAHOTEL") ON DELETE SET NULL ENABLE, 
	 CONSTRAINT "HOTELIN_FK" FOREIGN KEY ("HOTEL")
	  REFERENCES  "HOTEL" ("IDHOTEL") ON DELETE SET NULL ENABLE
   )
/
CREATE TABLE  "EGRESOS" 
   (	"IDEGRESO" NUMBER(9,0), 
	"FECHAEGRESO" DATE, 
	"NOMBREPRODUCTOEGRESADO" VARCHAR2(90), 
	"CANTIDADEGRESADA" NUMBER(10,0), 
	"INVENTARIO" NUMBER(9,0), 
	 CONSTRAINT "EGRESOS_PK" PRIMARY KEY ("IDEGRESO") ENABLE, 
	 CONSTRAINT "INVENTARIOEGRESO_FK" FOREIGN KEY ("INVENTARIO")
	  REFERENCES  "INVENTARIO" ("IDINVENTARIO") ON DELETE SET NULL ENABLE
   )
/
CREATE TABLE  "MUNICIPIO" 
   (	"IDMUNICIPIO" NUMBER(9,0), 
	"NOMBREMUNICIPIO" VARCHAR2(60), 
	"DEPARTAMENTO" NUMBER(9,0), 
	 CONSTRAINT "IDMUNICIPIO_PK" PRIMARY KEY ("IDMUNICIPIO") ENABLE, 
	 CONSTRAINT "DEPARTAMENTO_FK" FOREIGN KEY ("DEPARTAMENTO")
	  REFERENCES  "DEPARTAMENTO" ("IDDEPARTAMENTO") ON DELETE SET NULL ENABLE
   )
/
CREATE TABLE  "HOTEL" 
   (	"IDHOTEL" NUMBER(9,0), 
	"NOMBREHOTEL" VARCHAR2(60), 
	"MUNICIPIO" NUMBER(9,0), 
	"DIRECCION" VARCHAR2(90), 
	"TELEFONO" NUMBER(9,0), 
	"CADENA" NUMBER(9,0), 
	 CONSTRAINT "IDHOTEL_PK" PRIMARY KEY ("IDHOTEL") ENABLE, 
	 CONSTRAINT "MUNICIPIO_FK" FOREIGN KEY ("MUNICIPIO")
	  REFERENCES  "MUNICIPIO" ("IDMUNICIPIO") ON DELETE SET NULL ENABLE, 
	 CONSTRAINT "CADENA_FK" FOREIGN KEY ("CADENA")
	  REFERENCES  "CADENAHOTEL" ("IDCADENAHOTEL") ON DELETE SET NULL ENABLE
   )
/
CREATE TABLE  "HABITACION" 
   (	"IDHABITACION" NUMBER(9,0), 
	"NUMEROHABITACION" NUMBER(9,0), 
	"TOTALCAMAS" NUMBER(9,0), 
	"TIPO" VARCHAR2(60), 
	"HOTEL" NUMBER(9,0), 
	 CONSTRAINT "IDHABITACION_PK" PRIMARY KEY ("IDHABITACION") ENABLE, 
	 CONSTRAINT "HOTEL_FK" FOREIGN KEY ("HOTEL")
	  REFERENCES  "HOTEL" ("IDHOTEL") ON DELETE SET NULL ENABLE
   )
/
CREATE TABLE  "INGRESOS" 
   (	"IDINGRESO" NUMBER(9,0), 
	"FECHAINGRESO" DATE, 
	"NOMBREPRODUCTOINGRESADO" VARCHAR2(90), 
	"CANTIDADINGRESADA" NUMBER(10,0), 
	"INVENTARIO" NUMBER(9,0), 
	 CONSTRAINT "INGRESOS_PK" PRIMARY KEY ("IDINGRESO") ENABLE, 
	 CONSTRAINT "INVENTARIOINGRESO_FK" FOREIGN KEY ("INVENTARIO")
	  REFERENCES  "INVENTARIO" ("IDINVENTARIO") ON DELETE SET NULL ENABLE
   )
/
CREATE TABLE  "RESTAURANTE" 
   (	"IDRESTAURANTE" NUMBER(9,0), 
	"NOMBRERESTAURANTE" VARCHAR2(60), 
	"DIRECCION" VARCHAR2(60), 
	"TELEFONO" NUMBER(9,0), 
	"HOTEL" NUMBER(9,0), 
	 CONSTRAINT "IDRESTAURANTE_PK" PRIMARY KEY ("IDRESTAURANTE") ENABLE, 
	 CONSTRAINT "HOTELREST_FK" FOREIGN KEY ("HOTEL")
	  REFERENCES  "HOTEL" ("IDHOTEL") ON DELETE SET NULL ENABLE
   )
/
CREATE TABLE  "MENURESTAURANTE" 
   (	"IDMENU" NUMBER(9,0), 
	"CLASEPLATO" NUMBER(9,0), 
	"PRECIO" NUMBER(9,0), 
	"DESCRIPCIONMENU" VARCHAR2(60), 
	"RESTAURANTE" NUMBER(9,0), 
	 CONSTRAINT "IDMENU_PK" PRIMARY KEY ("IDMENU") ENABLE, 
	 CONSTRAINT "RESTAURANTE_FK" FOREIGN KEY ("RESTAURANTE")
	  REFERENCES  "RESTAURANTE" ("IDRESTAURANTE") ON DELETE SET NULL ENABLE
   )
/
CREATE TABLE  "RESERVA" 
   (	"IDRESERVA" NUMBER(9,0), 
	"CLIENTERESERVA" NUMBER(9,0), 
	"HABITACION" NUMBER(9,0), 
	"HORARESERVA" VARCHAR2(60), 
	"FECHARESERVA" VARCHAR2(90), 
	 CONSTRAINT "IDRESERVA_PK" PRIMARY KEY ("IDRESERVA") ENABLE, 
	 CONSTRAINT "CLIENTERESERVA_FK" FOREIGN KEY ("CLIENTERESERVA")
	  REFERENCES  "CLIENTE" ("IDCLIENTE") ON DELETE SET NULL ENABLE, 
	 CONSTRAINT "HABITACION_FK" FOREIGN KEY ("HABITACION")
	  REFERENCES  "HABITACION" ("IDHABITACION") ENABLE
   )
/
CREATE TABLE  "ROL_EMPLEADO" 
   (	"ID_ROL" NUMBER NOT NULL ENABLE, 
	"DESCRIPCION" VARCHAR2(4000) NOT NULL ENABLE, 
	 CONSTRAINT "ROL_EMPLEADO_PK" PRIMARY KEY ("ID_ROL") ENABLE
   )
/
CREATE TABLE  "USUARIO" 
   (	"LOGIN" VARCHAR2(20), 
	"PASSWORD" VARCHAR2(60), 
	"ROLEMPLEADO" NUMBER(9,0), 
	"CEDULA" NUMBER(10,0), 
	"NOMBRE" VARCHAR2(4000), 
	 CONSTRAINT "IDUSUARIO_PK" PRIMARY KEY ("LOGIN") ENABLE, 
	 CONSTRAINT "USUARIOROL_FK" FOREIGN KEY ("ROLEMPLEADO")
	  REFERENCES  "ROL_EMPLEADO" ("ID_ROL") ENABLE
   )
/
 CREATE SEQUENCE   "CONVENIO_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE  NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "CLIENTE_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 8 NOCACHE  NOORDER  NOCYCLE
/
CREATE OR REPLACE TRIGGER  "BI_CONVENIO" 
  before insert on "CONVENIO"               
  for each row  
begin   
    select "CONVENIO_SEQ".nextval into :NEW.IDCONVENIO from dual; 
end;
/
ALTER TRIGGER  "BI_CONVENIO" ENABLE
/
CREATE OR REPLACE TRIGGER  "BI_CLIENTE" 
  before insert on "CLIENTE"               
  for each row  
begin   
    select "CLIENTE_SEQ".nextval into :NEW.IDCLIENTE from dual; 
end;
/
ALTER TRIGGER  "BI_CLIENTE" ENABLE
/